var thismake;
var currentpagemake=1;
var startmake=0;
var countmake=5;
var makesarray;
var MakeProxy = Objs("model.MakeProxy",
	Proxy,
{
	initialize: function( name,lists)
	{ 
		MakeProxy.$super.initialize.call( this, name,lists);
		thismake=this;
	},	
	load:function()
	{
		var pagelimit=new Object();
		pagelimit.start=startmake;
		pagelimit.count=countmake;
		pagelimit.searchkey=$("#searchmake").val();
		$.ajax({
				type: "POST",
				url:"../services/VehicleNameService.php?action=getAllMakes",
				data:pagelimit,
				success: function(data,status) {
				var makedata= eval('(' + data + ')');
				
				thismake.sendNotification( NotificationNames.MAKEDATA, makedata );	
					
				},
				error:function(error,response){
				}
			});
	},
	editMake:function(makeObj)
	{
	
		$.ajax({
				type: "POST",
				url:"../services/VehicleNameService.php?action=editMake",
				data:makeObj,
				success: function(makeObj,status) {

					$("#searchmake").val('');
					$('#editMakePopup').modal('hide');
					thismake.load();
					thismake.getmakes();
					bootbox.alert("Update Success");
					
				},
				error:function(error,response){
				
					bootbox.alert("Edit Failed");
					
				}
			});
			
	},
	save:function()
	{
		var makeobject=new Object();
		makeobject.make=$("#make").val();
		makeobject.description=$("#Description").val();
		makeobject.created_by=global_user.admin_id;
		$('#makepopup').modal('hide');
		$('#progress').show();
		$.ajax({
				type: "POST",
				url:"../services/VehicleNameService.php?action=addMake",
				data:makeobject,
				success: function(data,status) {
					//var makedata= eval('(' + data + ')');
					$('#progress').hide();
					thismake.load();	
					thismake.getmakes();	
					$("#make").val('');	
					$("#Description").val('');	
					bootbox.alert("Make Saved Successfully");
				},
				error:function(error,response){
				}
			});
	},
	getmakes:function()
	{
		
		$.ajax({
				type: "POST",
				url:"../services/VehicleNameService.php?action=getMakes",
				success: function(data,status) {
				var makes= eval('(' + data + ')');
				thismake.sendNotification( NotificationNames.MAKES, makes );	
					makesarray=makes;
				},
				error:function(error,response){
				}
			});
	},
	deleteMake:function(makeObj)
	{
		
		$.ajax({
				type: "POST",
				url:"../services/VehicleNameService.php?action=deleteMake",
				data:makeObj,
				success: function(makeObj,status) {
					//alert(status.result);
					bootbox.alert("Delete Success");
					$("#searchmake").val('');
					thismake.load();
					thismake.getmakes();	
				},
				error:function(error,response){
				}
			});
	}
	
});
 